package com.t01.bdqn.design.proxy.stati;

import com.t01.bdqn.design.factory.student.Student;

public class StudentProxy implements Student {

    /**
     * 被代理的目标对象
     */
    private Student target;

    public StudentProxy(Student student){
        this.target = student;
    }

    /**
     * 对目标对象业务进行代理
     */
    @Override
    public String getName() {
        before();
        //原本代码正常执行
        String name = target.getName();
        after();
        return name;
    }

    public void before() {
        System.out.println("子类方法前处理");
    }

    public void after() {
        System.out.println("子类方法后处理");
    }

}
